<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <title>注册 - 五四宪法历史资料陈列馆</title>
    <link rel="stylesheet" href="static/css/style.css">
    <script src="static/js/jquery.min.js"></script>
    <script src="static/js/common.js"></script>
</head>
<body>
<div class="main">
    <div class="top login-top">
        <a class="back" href="javascript:history.back(-1)"><img src="static/image/left1.png" alt="">返回</a>
    </div>
    <div class="login">
        <p class="login-header">博物馆预约</p>
        <form action="register" method="post" id="register">
            <div class="login-body">
                <p>
                    <img src="static/image/login-t.png" alt="">
                    <input type="text" placeholder="请输入手机号码" id="mobile" onblur="checkMobile(this.value)" name="mobile">
                </p>
                <p>
                    <img src="static/image/login-n.png" alt="">
                    <input type="text" placeholder="请输入用户名" id="name" name="nickname">
                </p>
                <p>
                    <img src="static/image/login-v.png" alt="">
                    <input type="password" placeholder="请输入密码" id="pwd" name="password">
                </p>
                <p>
                    <img src="static/image/login-v.png" alt="">
                    <input type="password" placeholder="请再次输入密码" id="pwd1" onblur="checkPwd()" name="repassword">
                </p>
                <a href="javascript:;" class="reg-submit" id="doReg" onclick="regSubmit()">注册</a>
            </div>
        </form>
    </div>
</div>
<script>
    flag = true;
    function checkMobile(tel) {
        var reg = /(^1[3|4|5|7|8][0-9]{9}$)/;
        //手机号格式正确
        if (reg.test(tel)) {
            return true;
        } else {
            layer.alert('手机号码有误，请确认。');
            flag = false;
            return false;
        }
    }

    function checkPwd(){
        var pwd = $('#pwd').val();
        var pwd1 = $('#pwd1').val();
        if(pwd != pwd1){
            layer.alert('两次密码输入不一致，请重新输入。');
            flag = false;
            return false;
        }
        if(pwd1.length<6){
            layer.alert('密码长度需大于6位');
            flag = false;
            return false;
        }
    }

    function regSubmit(){
        var input = $('.login-body input');
        for(var i=0;i<input.length;i++){
            if($(input[i]).val() == ""){
                layer.alert("请填写" + $(input[i]).attr('name'));
                return false;
            }
        }

        if(flag)$('#register').submit();

    }
</script>
</body>
</html>